home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 01 Manslow / GAPBILExample / GAPBILExampleView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-07  |  2.3 KB  |  104 lines

  1. //GAPBILExample
  2. //Copyright John Manslow
  3. //29/09/2001
  4.  
  5. // GAPBILExampleView.cpp : implementation of the CGAPBILExampleView class
  6. //
  7.  
  8. #include "stdafx.h"
  9. #include "GAPBILExample.h"
  10.  
  11. #include "GAPBILExampleDoc.h"
  12. #include "GAPBILExampleView.h"
  13.  
  14. #include "CWorld.h"
  15.  
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CGAPBILExampleView
  24.  
  25. IMPLEMENT_DYNCREATE(CGAPBILExampleView, CView)
  26.  
  27. BEGIN_MESSAGE_MAP(CGAPBILExampleView, CView)
  28.     //{{AFX_MSG_MAP(CGAPBILExampleView)
  29.     ON_WM_TIMER()
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. extern CWorld *pWorld;
  34. extern void Evaluate(void);
  35. CGAPBILExampleView *pView;
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CGAPBILExampleView construction/destruction
  39.  
  40. CGAPBILExampleView::CGAPBILExampleView()
  41. {
  42.     //This is used in the document to draw to the window
  43.     pView=this;
  44. }
  45.  
  46. CGAPBILExampleView::~CGAPBILExampleView()
  47. {
  48. }
  49.  
  50. BOOL CGAPBILExampleView::PreCreateWindow(CREATESTRUCT& cs)
  51. {
  52.     // TODO: Modify the Window class or styles here by modifying
  53.     //  the CREATESTRUCT cs
  54.  
  55.     return CView::PreCreateWindow(cs);
  56. }
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CGAPBILExampleView drawing
  60.  
  61. void CGAPBILExampleView::OnDraw(CDC* pDC)
  62. {
  63.     CGAPBILExampleDoc* pDoc = GetDocument();
  64.     ASSERT_VALID(pDoc);
  65.  
  66.     //Redraw the world
  67.     pWorld->Draw(pDC);
  68.  
  69.     //Set the timer that calls the main loop
  70.     SetTimer(0,0,NULL);
  71. }
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CGAPBILExampleView diagnostics
  75.  
  76. #ifdef _DEBUG
  77. void CGAPBILExampleView::AssertValid() const
  78. {
  79.     CView::AssertValid();
  80. }
  81.  
  82. void CGAPBILExampleView::Dump(CDumpContext& dc) const
  83. {
  84.     CView::Dump(dc);
  85. }
  86.  
  87. CGAPBILExampleDoc* CGAPBILExampleView::GetDocument() // non-debug version is inline
  88. {
  89.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGAPBILExampleDoc)));
  90.     return (CGAPBILExampleDoc*)m_pDocument;
  91. }
  92. #endif //_DEBUG
  93.  
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CGAPBILExampleView message handlers
  96.  
  97. void CGAPBILExampleView::OnTimer(UINT nIDEvent) 
  98. {
  99.     KillTimer(0);    
  100.     CView::OnTimer(nIDEvent);
  101.     Evaluate();
  102.     SetTimer(0,0,NULL);
  103. }
  104.